home *** CD-ROM | disk | FTP | other *** search
/ BMUG Revelations / BMUG Revelations.toast / Programming / Programming Languages / Yerk 3.64 / Supplement / TCON example
Text File  |  1991-01-01  |  2KB  |  66 lines

  1. \ these values are used by text constant at run time for
  2. \ centering text.
  3.      0 Value tcLeft
  4.    472 Value tcRt
  5.  
  6. \ tcMode determines the textMode for compiled text constants
  7. srcOr Value tcMode
  8.  
  9. -1 Constant Ctr    \ causes text to be centered
  10.  
  11. \ ( addr offs -- )  fetch addr + offs as a Toolbox Int
  12. : @int   + w@ makeInt ;
  13.  
  14. \ ( addr:str255 -- centerX )  compute center val for text
  15. : tCenter
  16.     +base >R word0 R> call StringWidth word0    \ width in pixels
  17.     2/ tcRt tcLeft - 2/ tcLeft + swap -  ;
  18.  
  19. \ Determine the proper Y value for the next line.  This is done
  20. \ by adding the offset plus height of this line to the Y
  21. \ value of the last line (specified in tCon)
  22.  
  23. \ ( height xVal offs -- height xVal yVal )
  24. : +lin  { ht xVal offs -- ht xVal yVal } ht xVal
  25.     latest pfa 2+ W@    \ get Y value of last tCon
  26.     ht + 4+ offs +  ;
  27.  
  28. \ NL calls +lin with an offset of 0
  29. : NL  0 +lin ;
  30.  
  31. \ Define a family of text constants that include formatting
  32. \ information.  When the name of the constant is used, it
  33. \ prints itself in the proper format on the current grafPort.
  34.  
  35. 1 Codefields
  36.     Do.. >R  R 4 @int    call TextSize
  37.         R 6 @int        call TextFace
  38.         R 8 @int        call TextFont
  39.         R 10 @int        call TextMode
  40.         R w@ dup ctr =    \ should we center the text?
  41.         IF drop R 12 +  tCenter THEN
  42.         R 2+ w@ gotoXY  R> 12 + Count Type  ..End
  43.  
  44. \ A text constant is specified in the following manner:
  45. \ font face size locX locY tCon name "Text to print"
  46. \ if locX is specified as -1, the constant will be centered within
  47. \ global values tcLeft and tcRt.
  48.  
  49. : tCon Build  swap w, w,    \ 0=locX, 2=locY
  50.     w, w, w, tcMode w,        \ 4=size, 6=face, 8=font, 10=mode
  51.     word" str,  ..End        \ 12=len:string... 12+len
  52.  
  53. \ Define text constants for the Demo.
  54. \ Font Face Size X Y --------------------
  55.  
  56.  4  0  9  20  165
  57. tcon  "cr1 "  "
  58.  0  0  12  20   nl
  59. tcon  "cr2 "Yerk Version 3.3.  Formerly Neon, by Kriya Systems, Inc."
  60.  2  0  12  20   nl
  61. tcon  "cr3 "Public Domain version.  Copying, use, and disclosure restricted by"
  62.  3  0  9  20   nl
  63. tcon  "cr4 "non-use of the word Neon"
  64.  
  65. : printMe -curs "cr1 "cr2 "cr3 "cr4 ;
  66.